<?php
/*
 *      Controller.php
 *
 *      Copyright 2010 Rakitin Vitaliy <virak@ukr.net>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

//require_once("./classes/View.php");
//require_once("./config.php");
//require_once("./class/DB.php");
//require_once("./class/nwmodel.php");
require_once("./classes/nwmainform.php");
require_once("./classes/System/osmetadata.php");


class Controller {

private $error;
private $result;
//private $model;


	function __construct() {

		$this->error = false;
		$this->result = false;
	}

	//function user_is_auth() {
	//	return isset($_SESSION['user_id']);
	//}

	function processData() {
		//   ession_start();
/*
		$field = $GLOBALS["metadata"]->objects->Сотрудники->fields->add();
		$field->name = "sokr";
		$field->type = "varchar";
		$field->length = 32;
		$field->save();
*/
        //$user_id = $_SESSION['user_id'];
		//session_unset();
		//$_SESSION['user_id'] = $user_id;
		//echo "<pre>";
		//print_r($GLOBALS["metadata"]->objects->Сотрудники->fields->getall());
		//echo "</pre>";
		$mainform = new nwmainform("uuidfc109fbce4ce7d3543a1b5b7c5ffb7a9");
		$mainform->show();
		//$dic = $GLOBALS["metadata"]->objects->ЕдиницыИзмерения;
		//echo $dic->listform->defaultbody();
		// Считывание информации с запроса
		//$this->userRequest();

		// Проверка авторизации
		//if (!$this->user_is_auth()) {
		//	echo View::displayAuth();
		//	return;
		//}


		// Вывод по умолчанию
/*
		if ($this->error)
			View::displayError($this->error);
		else
		if ($this->result)
			View::displayResults($this->result);
		else
			echo View::displayDefault();
*/

		//echo "<pre>";
		//print_r($_POST);
		//echo "</pre>";

	}

	function userRequest() {
		// Так называемый роутер
		
		if (isset($_POST['owner'])) {
			//echo "<pre>";
		//			print_r($_POST);
		//echo "</pre>";
			switch ($_POST['owner']) {

				case 'menu':
					//$_SESSION['navigator'] = $_POST['id'];
				break;

				case 'navigator':
					$_SESSION['object'] = $_POST['object'];
					//echo "<pre>";
					//print_r($_SESSION['object']);
					//echo "</pre>";
				break;

				case 'properties':
					//eval($_POST['action']);
				break;

				case 'table':
					//eval($_POST['action']);
					//eval($_POST[1]);

				break;

				// Выход
				case 'logout':
					//$model->users->logout();
				break;
				// Логин
				case 'auth':
					//$model->users->login($_POST['login'], md5($_POST['pass']));
				break;
			}
		}
	}

}
?>
